home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / hopes_babysitting_maze.swf / scripts / __Packages / HopeBSM_engine.as
Text File  |  2011-08-19  |  10KB  |  346 lines

  1. class HopeBSM_engine
  2. {
  3.    var TARGETSCORE = 11000;
  4.    var endGameTimer_max = 16;
  5.    var GAMEQUAL = "MEDIUM";
  6.    var LOWQUAL_PROC = 5000;
  7.    function HopeBSM_engine()
  8.    {
  9.    }
  10.    function init(t_root, t_placeholder)
  11.    {
  12.       this.gameRoot = t_root;
  13.       this.gamePlaceholder = t_placeholder;
  14.       this.loadTime = getTimer();
  15.       trace("-- Init Hope Babysitting Maze Engine --");
  16.       this.hasPlayed = false;
  17.       this.soundMC = this.gamePlaceholder.createEmptyMovieClip("soundEngine_mc",3300);
  18.       this.soundEngine = new smashing.SoundEngine(this.soundMC,1,false);
  19.       this.soundEngine.createSound("music","Housemelody 22-03.wav");
  20.       this.soundEngine.createSound("puppy","Dog 2 Barks.wav");
  21.       this.soundEngine.createSound("pickup","squeak07.wav");
  22.       this.soundEngine.createSound("pickupSP","squeak07.wav");
  23.       this.soundEngine.createSound("pickupFinal","nicechime.wav");
  24.       this.interval = new smashing.IntervalEngine(this,"stepFrame");
  25.       this.interval.startFast();
  26.       this.pause();
  27.       this.loadLevelData();
  28.       this.goTitle();
  29.    }
  30.    function olr(event)
  31.    {
  32.       _global.RYMengine.onCheckLoginResponse(event);
  33.    }
  34.    function onCheckLoginResponse(event)
  35.    {
  36.       if(event.loggedIn == false)
  37.       {
  38.          this.loggedInUser = "";
  39.       }
  40.       else
  41.       {
  42.          this.loggedInUser = event.loggedIn;
  43.       }
  44.    }
  45.    function oli(event)
  46.    {
  47.       _global.RYMengine.onLogIn(event);
  48.    }
  49.    function onLogIn(event)
  50.    {
  51.       this.loggedInUser = event.username;
  52.    }
  53.    function olo(event)
  54.    {
  55.       _global.RYMengine.onLogOut(event);
  56.    }
  57.    function onLogOut(event)
  58.    {
  59.       this.loggedInUser = "";
  60.    }
  61.    function playMusic()
  62.    {
  63.       this.soundEngine.playSound("music",10000);
  64.    }
  65.    function stopMusic()
  66.    {
  67.       this.soundEngine.stopSound("music");
  68.    }
  69.    function playSound(t_name, t_loops)
  70.    {
  71.       this.soundEngine.playSound(t_name);
  72.    }
  73.    function stopSound(t_name)
  74.    {
  75.       if(t_name == undefined)
  76.       {
  77.          t_name = "music";
  78.       }
  79.       this.soundEngine.stopSound(t_name);
  80.    }
  81.    function changeVolume(t_vol)
  82.    {
  83.       this.soundEngine.changeVolume(t_vol);
  84.    }
  85.    function addScore(t_val)
  86.    {
  87.       this.n_score += t_val;
  88.       this.updateScore();
  89.    }
  90.    function loseScore()
  91.    {
  92.       this.n_score -= 50;
  93.       if(this.n_score < 0)
  94.       {
  95.          this.n_score = 0;
  96.       }
  97.       this.updateScore();
  98.    }
  99.    function updateScore()
  100.    {
  101.       this.gameRoot.txt_score.txt_score.text = this.n_score;
  102.    }
  103.    function startScript(t_script)
  104.    {
  105.       trace("- Start Script : " + t_script);
  106.       this.currentScript = t_script;
  107.       if(t_script === "meetBaby")
  108.       {
  109.          this.finishScript("meetBaby");
  110.       }
  111.    }
  112.    function finishScript(t_script)
  113.    {
  114.       trace("- Finish Script : " + t_script);
  115.       if(t_script === "meetBaby")
  116.       {
  117.          this.beatLevel();
  118.       }
  119.    }
  120.    function stepFrame(t_elapsed)
  121.    {
  122.       if(!this.paused)
  123.       {
  124.          this.a_levels[this.n_currentLevel].step(t_elapsed);
  125.       }
  126.    }
  127.    function startGame()
  128.    {
  129.       this.reset();
  130.       this.goGameplay();
  131.       this.startLevel();
  132.       this.hasPlayed = true;
  133.    }
  134.    function stopGame()
  135.    {
  136.       trace("- Stop and Clear game -");
  137.       this.stopSound();
  138.       this.pause();
  139.       this.clearLevel();
  140.    }
  141.    function reset()
  142.    {
  143.       this.n_currentLevel = 0;
  144.       this.currentScript = "finish";
  145.       this.n_score = 0;
  146.       this.pause();
  147.    }
  148.    function pause()
  149.    {
  150.       _quality = "HIGH";
  151.       this.stopMusic();
  152.       trace("Pause");
  153.       this.stopSound("dance");
  154.       this.paused = true;
  155.    }
  156.    function unpause()
  157.    {
  158.       _quality = this.GAMEQUAL;
  159.       trace("UnPause");
  160.       this.paused = false;
  161.    }
  162.    function goHopePage()
  163.    {
  164.       getUrl("/hope", "");
  165.    }
  166.    function goEverMe()
  167.    {
  168.       getUrl("/everme", "");
  169.    }
  170.    function quitForHighscore()
  171.    {
  172.       this.stopGame();
  173.       this.goHighscore();
  174.    }
  175.    function goHighscore()
  176.    {
  177.       this.gameRoot.gotoAndStop("highscore");
  178.       this.submitScore();
  179.    }
  180.    function submitScore()
  181.    {
  182.       this.gameRoot.txt_debug.text = this.activityid + " , " + this.n_score;
  183.       trace(this.loadTime);
  184.       var _loc2_ = getTimer() - this.loadTime;
  185.       this.module.dispatchEvent({type:"onAddModule",name:"submitScore_mc",content:"/modules/submitScore.swf",z:"top",gameid:this.activityid,score:this.n_score,time:_loc2_,silent:false,reload:true});
  186.       this.module.onScoreSubmitted = this.oss;
  187.       this.module.dispatchEvent({type:"onRegisterModuleListener",moduleName:"submitScore_mc",eventName:"onScoreSubmitted"});
  188.    }
  189.    function oss(event)
  190.    {
  191.       _global.hopeBSMrootPath.hopeBSMEngine.onScoreSubmitted(event);
  192.    }
  193.    function onScoreSubmitted(event)
  194.    {
  195.       if(this.n_score >= this.TARGETSCORE && this.loggedInUser != "")
  196.       {
  197.          this.goEverAward();
  198.       }
  199.       else
  200.       {
  201.          this.goTitle();
  202.       }
  203.    }
  204.    function startOver()
  205.    {
  206.       this.stopGame();
  207.       this.startGame();
  208.       this.gameRoot.house_mc.crib_mc.baby_mc.gotoAndStop("happy");
  209.       this.gameRoot.house_mc.crib_mc.baby_mc.anim.gotoAndPlay(1);
  210.    }
  211.    function goTitle()
  212.    {
  213.       this.pause();
  214.       this.gameRoot.gotoAndStop("title");
  215.    }
  216.    function goQuit()
  217.    {
  218.       this.pause();
  219.       this.gameRoot.gotoAndStop("quit");
  220.       this.gameRoot.window_mc.n_score = this.n_score;
  221.    }
  222.    function goEverAward()
  223.    {
  224.       this.gameRoot.gotoAndStop("everAward");
  225.    }
  226.    function goHelp()
  227.    {
  228.       this.pause();
  229.       this.gameRoot.gotoAndStop("help");
  230.    }
  231.    function leaveMenu()
  232.    {
  233.       this.goGameplay();
  234.       this.unpause();
  235.    }
  236.    function beatLevel()
  237.    {
  238.       this.pause();
  239.       this.n_score += 200 * this.n_currentLevel + 200;
  240.       this.n_score += Math.floor(this.a_levels[this.n_currentLevel].n_timer) * 50;
  241.       this.updateScore();
  242.       this.clearLevel();
  243.       if(this.n_currentLevel == 2)
  244.       {
  245.          this.beatGame();
  246.       }
  247.       else
  248.       {
  249.          this.gameRoot.gotoAndStop("levelend");
  250.       }
  251.    }
  252.    function getTimeSpent()
  253.    {
  254.       var _loc2_ = this.a_levels[this.n_currentLevel].n_timerMax - this.a_levels[this.n_currentLevel].n_timer;
  255.       this.a_levels[this.n_currentLevel].previousCompleteTime = _loc2_;
  256.       var _loc3_ = String(Math.ceil(_loc2_));
  257.       return _loc3_;
  258.    }
  259.    function getTotalTimeSpent()
  260.    {
  261.       var _loc3_ = 0;
  262.       var _loc2_ = this.a_levels.length;
  263.       while(true)
  264.       {
  265.          _loc2_;
  266.          if(!_loc2_--)
  267.          {
  268.             break;
  269.          }
  270.          _loc3_ += this.a_levels[_loc2_].previousCompleteTime;
  271.       }
  272.       var _loc4_ = String(Math.ceil(_loc3_));
  273.       return _loc4_;
  274.    }
  275.    function beatGame()
  276.    {
  277.       this.pause();
  278.       this.gameRoot.gotoAndStop("levelend2");
  279.    }
  280.    function gameOver()
  281.    {
  282.       this.pause();
  283.       this.gameRoot.gotoAndStop("gameover");
  284.       this.gameRoot.house_mc.crib_mc.baby_mc.gotoAndStop("cry2");
  285.       this.gameRoot.window_mc.n_score = this.n_score;
  286.    }
  287.    function goGameplay()
  288.    {
  289.       this.playMusic();
  290.       this.gameRoot.gotoAndStop("game");
  291.       this.gameRoot.txt_lvl.gotoAndStop(this.n_currentLevel + 1);
  292.       this.gameRoot.icons_lvl.gotoAndStop(this.n_currentLevel + 1);
  293.       this.updateScore();
  294.       this.unpause();
  295.    }
  296.    function goGameWin()
  297.    {
  298.       this.gameRoot.gotoAndStop("wingame");
  299.       this.gameRoot.window_mc.n_score = this.n_score;
  300.    }
  301.    function startLevel()
  302.    {
  303.       trace("-- Start Level " + (this.n_currentLevel + 1) + " -- ");
  304.       this.activeGame = this.gamePlaceholder.createEmptyMovieClip("game",1);
  305.       this.a_levels[this.n_currentLevel].start(this.activeGame);
  306.       this.unpause();
  307.    }
  308.    function restartLevel()
  309.    {
  310.       eval(this.gameRoot + ".enter_" + this.a_levels[this.n_currentLevel].store).gotoAndStop("hidden");
  311.       this.startLevel();
  312.       this.gameRoot.gotoAndPlay("loseOutro");
  313.       this.goGameplay();
  314.    }
  315.    function nextLevel()
  316.    {
  317.       this.n_currentLevel = this.n_currentLevel + 1;
  318.       this.startLevel();
  319.       this.goGameplay();
  320.    }
  321.    function clearLevel()
  322.    {
  323.       this.a_levels[this.n_currentLevel].clear();
  324.       this.activeGame.removeMovieClip();
  325.    }
  326.    function loadLevelData()
  327.    {
  328.       this.a_levels = [new Classes.bsmLevel(this),new Classes.bsmLevel(this),new Classes.bsmLevel(this)];
  329.       var _loc2_ = this.a_levels[0];
  330.       _loc2_.playerData = {assetID:"player_mc",x:111,y:235};
  331.       _loc2_.iconData = [{x:344,y:64,special:3},{x:236,y:110,special:0},{x:307,y:236,special:1},{x:236,y:236,special:4},{x:236,y:170,special:2},{x:117,y:166,special:6},{x:117,y:37,special:5}];
  332.       _loc2_.iconFrameNum = 1;
  333.       _loc2_.enemyData = [{assetID:"puppy_mc",startPoint:"point23",type:"puppy",speed:40}];
  334.       _loc2_ = this.a_levels[1];
  335.       _loc2_.playerData = {assetID:"player_mc",x:111,y:235};
  336.       _loc2_.iconData = [{x:105,y:69,special:3},{x:105,y:130,special:6},{x:237,y:61,special:5},{x:237,y:127,special:4},{x:423,y:232,special:2},{x:314,y:49,special:1},{x:386,y:49,special:6},{x:387,y:129,special:1},{x:446,y:98,special:0}];
  337.       _loc2_.iconFrameNum = 2;
  338.       _loc2_.enemyData = [{assetID:"puppy_mc",startPoint:"point20",type:"puppy",speed:50}];
  339.       _loc2_ = this.a_levels[2];
  340.       _loc2_.playerData = {assetID:"player_mc",x:111,y:235};
  341.       _loc2_.iconData = [{x:156,y:123,special:3},{x:156,y:82,special:6},{x:237,y:110,special:8},{x:237,y:170,special:7},{x:237,y:236,special:1},{x:401,y:232,special:0},{x:237,y:56,special:9},{x:320,y:320,special:2},{x:457,y:320,special:10},{x:543,y:320,special:11},{x:553,y:151,special:4},{x:552,y:54,special:5},{x:443,y:44,special:1}];
  342.       _loc2_.iconFrameNum = 3;
  343.       _loc2_.enemyData = [{assetID:"puppy_mc",startPoint:"point7",type:"puppy",speed:60}];
  344.    }
  345. }
  346.